package com.ybkj.daijia.server.model;

import com.fasterxml.jackson.annotation.JsonGetter;
import java.beans.Transient;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;

public class ChartMonth extends Base {

    /**
     *
     */
    private static final long serialVersionUID = -4006303565058471642L;

    private Long yearId;

    private int month;

    private long totalSuccessNum;// 已成交单量

    private long totalCancelNum;// 已销单量

    private BigDecimal totalPrice;// 总价

    private List<ChartDay> chartDays;

    public Long getYearId() {
        return yearId;
    }

    public void setYearId(Long yearId) {
        this.yearId = yearId;
    }

    public long getTotalSuccessNum() {
        return totalSuccessNum;
    }

    public void setTotalSuccessNum(long totalSuccessNum) {
        this.totalSuccessNum = totalSuccessNum;
    }

    public long getTotalCancelNum() {
        return totalCancelNum;
    }

    public void setTotalCancelNum(long totalCancelNum) {
        this.totalCancelNum = totalCancelNum;
    }

    public BigDecimal getTotalPrice() {
        if (null == totalPrice) {
            return BigDecimal.ZERO;
        }
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public List<ChartDay> getChartDays() {
        return chartDays;
    }

    public void setChartDays(List<ChartDay> chartDays) {
        this.chartDays = chartDays;
    }

    @Transient
    @JsonGetter
    public int getDays() {

        Calendar calendar = Calendar.getInstance();
        //calendar.set(Calendar.YEAR, getYear().getYear());
        calendar.set(Calendar.MONTH, getMonth());

        return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);// 获取每月最大一天
    }


    @Override
    public String toString() {
        return "ChartMonth{" +
            "yearId=" + yearId +
            ", month=" + month +
            ", totalSuccessNum=" + totalSuccessNum +
            ", totalCancelNum=" + totalCancelNum +
            ", totalPrice=" + totalPrice +
            ", chartDays=" + chartDays +
            '}';
    }
}
